#! /usr/bin/env python
# -*- coding: utf-8
from __future__ import unicode_literals, absolute_import

from rest_framework import serializers

from prd.models import *
from prj.models import *
from django.contrib.auth.models import User, Group

class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ('url', 'username', 'email', 'groups')


class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        fields = ('url', 'name')

'''all projects info'''
class TypeInfoSerializer(serializers.Serializer):
    type_name = serializers.CharField(max_length=32)
class WorkerInfoSerializer(serializers.Serializer):
    worker_name = serializers.CharField(max_length=64)
class StatusInfoSerializer(serializers.Serializer):
    status_name = serializers.CharField(max_length=32)

class PrjSerializer(serializers.HyperlinkedModelSerializer):
    type_number = TypeInfoSerializer()
    pm_name = WorkerInfoSerializer()
    status_name = StatusInfoSerializer()

    class Meta:
        model = Detail_info
        fields = '__all__'

'''all produce info'''
class UpdateStatusSerializer(serializers.Serializer):
    update_status_name = serializers.CharField(max_length=32)
class YearPlanSerializer(serializers.Serializer):
    year_plan_name = serializers.CharField(max_length=32)
class UpdateTypeSerializer(serializers.Serializer):
    update_type_name = serializers.CharField(max_length=32)
class TaskStatusSerializer(serializers.Serializer):
    task_status_name = serializers.CharField(max_length=32)

class PrdSerializer(serializers.HyperlinkedModelSerializer):
    update_status_number = UpdateStatusSerializer()
    year_plan_number = YearPlanSerializer()
    update_type_number = UpdateTypeSerializer()
    #update_coder_number = WorkerInfoSerializer
    task_status_number = TaskStatusSerializer()
    #update_manager_number = WorkerInfoSerializer()
    #project_info_number = PrjSerializer()

    class Meta:
        model = Update_info
        #fields = '__all__'
        exclude = ('update_coder_number','update_manager_number','project_info_number')